// localStorage.clear();

// 历史登录记录渲染
var acc = localStorage.getItem('acount');
var pw = localStorage.getItem('pwd');
if (acc && pw) {
    $('.account input')[0].value = acc;
    $('.psw input')[0].value = pw;
}
// 设置登录状态,默认为未登录
var isLogin = false;
// 登录
var flag = false;
$('.login button').click(function () {
    let account = $('.account input').val();
    let pwd = $('.psw input').val();
    userData.forEach((user) => {
        if (account == user.account && pwd == user.pwd) {
            flag = true;
            localStorage.setItem('name',user.name);
            localStorage.setItem('img',user.img)
            localStorage.setItem('acount', account);
            localStorage.setItem('pwd', pwd);
            let oderList= JSON.stringify(user.order);
            localStorage.setItem('order',oderList);
        }
    })
    if (flag) {
        isLogin=true;
        location.href = './index.html';
        flag = false;
    }else{
        isLogin=false;
        alert('账号或密码错误,请重新输入');
    }
    localStorage.setItem('isLogin', isLogin);
})